home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / Xpm / pixmap / PixmapP.h < prev    next >
C/C++ Source or Header  |  1994-08-01  |  8KB  |  238 lines

  1. /* * Last edited: Dec 19 15:29 1991 (mallet) */
  2. /*
  3.  * $Id: PixmapP.h,v 1.10 1992/10/27 08:39:10 mallet Exp $
  4.  * 
  5.  * Copyright 1991 Lionel Mallet
  6.  * 
  7.  * Permission to use, copy, modify, distribute, and sell this software and its
  8.  * documentation for any purpose is hereby granted without fee, provided that
  9.  * the above copyright notice appears in all copies and that both that
  10.  * copyright notice and this permission notice appear in supporting
  11.  * documentation, and that the name of Lionel MALLET not be used in
  12.  * advertising or publicity pertaining to distribution of the software
  13.  * without specific, written prior permission.  Lionel MALLET makes no
  14.  * representations about the suitability of this software for any
  15.  * purpose.  It is provided "as is" without express or implied warranty.
  16.  *
  17.  * Lionel MALLET DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
  18.  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  19.  * FITNESS, IN NO EVENT SHALL Lionel MALLET BE LIABLE FOR ANY SPECIAL,
  20.  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
  21.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION 
  22.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  23.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  *  This software is opened and free. Furthermore, everybody is kindly
  26.  * invited to participate to improve it for the benefit of all.
  27.  * Improvements can be new features, bugs fixes and porting issues
  28.  * resolution.
  29.  *
  30.  * Author:  Lionel Mallet, SIMULOG
  31.  */
  32.  
  33. /*
  34.  * $XConsortium: PixmapP.h,v 1.6 90/06/09 20:19:47 dmatic Exp $
  35.  *
  36.  * Copyright 1989 Massachusetts Institute of Technology
  37.  *
  38.  * Permission to use, copy, modify, distribute, and sell this software and its
  39.  * documentation for any purpose is hereby granted without fee, provided that
  40.  * the above copyright notice appear in all copies and that both that
  41.  * copyright notice and this permission notice appear in supporting
  42.  * documentation, and that the name of M.I.T. not be used in advertising or
  43.  * publicity pertaining to distribution of the software without specific,
  44.  * written prior permission.  M.I.T. makes no representations about the
  45.  * suitability of this software for any purpose.  It is provided "as is"
  46.  * without express or implied warranty.
  47.  *
  48.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  49.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  50.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  51.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  52.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  53.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  54.  *
  55.  * Author:  Davor Matic, MIT X Consortium
  56.  */
  57.  
  58.  
  59.  
  60. #ifndef _PixmapP_h
  61. #define _PixmapP_h
  62.  
  63. #include "Pixmap.h"
  64. #include <X11/CoreP.h>
  65.  
  66. typedef struct {
  67.     Atom           *targets;
  68.     Cardinal        num_targets;
  69.     PWRequestRec   *requests;
  70.     Cardinal        num_requests;
  71.     PWRequestRec   *request[100];
  72.   
  73. } PixmapClassPart;
  74.  
  75. /* Full class record declaration */
  76. typedef struct _PixmapClassRec {
  77.   CoreClassPart          core_class;
  78.   PixmapClassPart        pixmap_class;
  79. } PixmapClassRec;
  80.  
  81. extern PixmapClassRec pixmapClassRec;
  82.  
  83. /**********/
  84. struct _PWRequestRec {
  85.   char       *name;
  86.   int         status_size;
  87.   void      (*engage)();
  88.   XtPointer     engage_client_data;
  89.   void      (*terminate)();
  90.   XtPointer     terminate_client_data;
  91.   void      (*remove)();
  92.   XtPointer     remove_client_data;
  93. };
  94.  
  95. typedef struct {
  96.   Position from_x, from_y,
  97.            to_x, to_y;
  98. } PWArea;
  99.  
  100. typedef struct {
  101.     PWRequestRec *request;
  102.     XtPointer       status;
  103.     Boolean       trap;
  104.     XtPointer       call_data;
  105. } PWRequestStack;
  106.  
  107. typedef struct {
  108.     XImage   *image, *mask_image, *buffer, *mask_buffer;
  109.     XPoint    hot;
  110.     Position  at_x, at_y;
  111.     Boolean   fold;
  112.     Boolean   grid;
  113.     Boolean   changed;
  114. } PWZoom;
  115.  
  116. typedef struct {
  117.     Boolean   own;
  118.     Boolean   limbo;
  119. } PWSelection;
  120.  
  121.  
  122. /* New fields for the Pixmap widget record */
  123. typedef struct {
  124.  
  125.   /* resources */
  126.  
  127.   Cursor           cursor;
  128.   Pixel            foreground_pixel;
  129.   Pixel            highlight_pixel;
  130.   Pixel            framing_pixel;
  131.   Pixel            transparent_pixel;
  132.   Pixmap           stipple;
  133.   Boolean          stippled;
  134.   Boolean          proportional;
  135.   Boolean          grid;
  136.   Dimension        grid_tolerance;
  137.   Boolean          axes;
  138.   Boolean          resize;
  139.   Dimension        distance, squareW, squareH, width, height;
  140.   int              button_action[5];
  141.   String           filename;
  142.   AddColorNotifyProc AddColorNotify;
  143.  
  144.   /* private state */
  145.  
  146.   int             nextensions, buffer_nextensions;
  147.   XpmExtension    *extensions, *buffer_extensions;
  148.   PWDrawPointProc drawPointCallback; 
  149.   PWRedrawProc    redrawCallback; 
  150.   PWTranslateProc translateCallback; 
  151.   PWRotateProc    rotateCallback; 
  152.   PWFlipProc      flipCallback; 
  153.  
  154.   XFontStruct     *font_struct;
  155.   String          text_string; 
  156.   int             text_lbearing, text_rbearing;
  157.   int             text_ascent, text_descent; 
  158.  
  159.   XPoint           hot;
  160.   XPoint           buffer_hot;
  161.   XPoint           storage_hot;
  162.   Pixel            clear_pixel;
  163.   Position         horizOffset, vertOffset;
  164.   void           (*notify)();
  165.   UseColorNotifyProc   colorNotify;
  166.   ExtensionNotifyProc  extensionNotify;
  167.   PickPixelProc    pickPixelDraw;
  168.   PickPixelProc    pickPixelComplete;
  169.   PWRequestStack  *request_stack;
  170.   Cardinal         cardinal, current;
  171.   /*Boolean          trapping;*/
  172.   XImage          *image, *mask_image, *buffer, *mask_buffer;
  173.   XImage          *storage, *mask_storage;
  174.   PWArea           mark, buffer_mark;
  175.   GC               drawing_gc;
  176.   GC               highlighting_gc;
  177.   GC               framing_gc;
  178.   GC               transparent_gc;
  179.   Boolean          changed;
  180.   Boolean          fold;
  181.   Boolean          zooming;
  182.   PWZoom           zoom;
  183.   XtPointer         *value;
  184.   char             status[80];
  185.   PWSelection      selection;
  186.   PWColorInfo    **colorTable;
  187.   char            *hints_cmt;
  188.   char            *colors_cmt;
  189.   char            *pixels_cmt;
  190. } PixmapPart;
  191.  
  192. /* Full instance record declaration */
  193. typedef struct _PixmapRec {
  194.   CorePart      core;
  195.   PixmapPart    pixmap;
  196. } PixmapRec;
  197.  
  198. /* Private functions */
  199.  
  200. #define InPixmapX(PW, x)\
  201.     (Position) (min((Position)((max(PW->pixmap.horizOffset, x)  -\
  202.                    PW->pixmap.horizOffset) /\
  203.                    PW->pixmap.squareW), PW->pixmap.width - 1))
  204.     
  205. #define InPixmapY(PW, y)\
  206.     (Position) (min((Position)((max(PW->pixmap.vertOffset, y)  -\
  207.                    PW->pixmap.vertOffset) /\
  208.                    PW->pixmap.squareH), PW->pixmap.height - 1))
  209.     
  210. #define InWindowX(PW, x)\
  211.     (Position) (PW->pixmap.horizOffset + ((x) * PW->pixmap.squareW))
  212.  
  213. #define InWindowY(PW, y)\
  214.     (Position) (PW->pixmap.vertOffset + ((y) * PW->pixmap.squareH))
  215.      
  216. #define QuerySet(x, y) (((x) != NotSet) && ((y) != NotSet))
  217.  
  218. #define QueryZero(x, y) (((x) == 0) || ((y) == 0))
  219.  
  220. #define Swap(x, y) {Position t; t = x; x = y; y = t;}
  221.  
  222. #define QuerySwap(x, y) if(x > y) Swap(x, y)
  223.  
  224. #define QueryInPixmap(PW, x, y)\
  225.   (((x) >= 0) && ((x) < PW->pixmap.image->width) &&\
  226.    ((y) >= 0) && ((y) < PW->pixmap.image->height))
  227.  
  228. #define Value(PW, button)   (PW->pixmap.button_action[button - 1])
  229.  
  230. XImage *GetImage();
  231. Pixmap GetPixmap();
  232. XImage *CreatePixmapImage();
  233. XImage *CreateMaskImage();
  234. void DestroyPixmapImage();
  235. #define DestroyMaskImage(mask) DestroyPixmapImage(mask)
  236.  
  237. #endif /* _PixmapP_h */
  238.